import React, { useEffect } from 'react'
import { useHistory, useLocation } from 'react-router-dom'

function yztoken(Com) {
    return function yztoken(props) {
        let history = useHistory()
        let location = useLocation()
        useEffect(() => {
            if (location.pathname !== "/login") {
                let token = localStorage.getItem('token')
                if (!token) {
                    history.push("/login")
                }
            }
        })
        return (<>
            <Com {...props} />
        </>
        )
    }
}
export default yztoken